package com.bwie.controller;

import com.bwie.common.domain.GroupActivity;
import com.bwie.common.domain.Product;
import com.bwie.common.domain.request.ActivityRequest;
import com.bwie.common.domain.response.ActivityProductListResponse;
import com.bwie.common.result.PageResult;
import com.bwie.common.result.Result;
import com.bwie.service.ActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Set;

/**
 * @className: ActivityConttroller
 * @Description: TODO
 * @version: v1.８.0
 * @author: 刘茂锴
 * @date: 2025/10/2 11:14
 */
@RestController
@RequestMapping("/activity")
@CrossOrigin
public class ActivityController {
    @Autowired
    private ActivityService activityService;

    //拼团列表
    @PostMapping("/list")
    public Result<PageResult<ActivityProductListResponse>> activityList(@RequestBody ActivityRequest activityRequest){
        PageResult<ActivityProductListResponse> list=activityService.activityList(activityRequest);
        return Result.success(list);
    }
    //添加拼团活动
    @PostMapping("/activityAdd")
    public Result activityAdd(@RequestBody GroupActivity groupActivity){
        activityService.activityAdd(groupActivity);
        return Result.success();
    }
    //商品下拉框
    @GetMapping("/productList")
    public Result productList(){
        List<Product> list=activityService.productList();
        return Result.success(list);
    }

    //发起拼团
    @GetMapping("/activityFaTuan/{activityId}")
    public Result activityFaTuan(@PathVariable("activityId")Integer activityId){
        activityService.activityFaTuan(activityId);
        return Result.success();
    }

    //参加拼团
    @GetMapping("/activityCanTuan/{activityId}")
    public Result activityCanTuan(@PathVariable("activityId")Integer activityId){
        activityService.activityCanTuan(activityId);
        return Result.success();
    }

    //分享生成二维码
    @PostMapping("/generateQrcode")
    public Result generateQrcode(Set<Long> ids){
        List<String> strings = activityService.generateQrcode(ids);
        return Result.success(strings);
    }

}
